package com.example.designpattenexample.observer;

import java.util.Vector;

public class ConcreteSubject implements Subject {

    private Vector<Observer> observers = new Vector<>();

    @Override
    public void attach(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyObserve() {
        for (Observer e: observers){
            e.update();
        }
    }

    public void change(){
        System.out.println("ConcreteSubject changed");
        this.notifyObserve();
    }
}
